package cn.jboa.entity;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name = "SYS_DEPARTMENT", schema = "SCOTT", catalog = "")
public class SysDepartment {
    private int id;
    private String name;
    private Set<SysEmployee> sysEmployees = new HashSet<SysEmployee>(0);

    @OneToMany(mappedBy = "sysDepartment",cascade = {CascadeType.ALL})
    public Set<SysEmployee> getSysEmployees() {
        return sysEmployees;
    }

    public void setSysEmployees(Set<SysEmployee> sysEmployees) {
        this.sysEmployees = sysEmployees;
    }

    @Id
    @Column(name = "ID")
    @GenericGenerator(name="incrementName",strategy="increment")
    @GeneratedValue(generator="incrementName")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "NAME")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SysDepartment that = (SysDepartment) o;

        if (id != that.id) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        return result;
    }
}
